/** uni-admin 缓存键名 */
export const uniAdminCacheKey = {
  theme: "uni-admin-theme" // 主题
};
export default {
  namespaced: true,
  state: {
    inited: false,
    navMenu: [],
    routes: [],
    theme: uni.getStorageSync(uniAdminCacheKey.theme) || "default"
  },
  mutations: {
    SET_ROUTES: (state, routes) => {
      state.routes = routes;
    },
    SET_THEME: (state, theme) => {
      // #ifdef H5
      document
        .getElementsByTagName("body")[0]
        .setAttribute("data-theme", theme);
      // #endif
      uni.setStorageSync(uniAdminCacheKey.theme, theme);
      state.theme = theme;
    }
  },
  actions: {
    setRoutes({ commit }, routes) {
      commit("SET_ROUTES", routes);
    }
  }
};
